package com.gosophia.orgManagement.action;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.gosophia.commons.web.action.BaseAjaxAction;
import com.gosophia.organizationManagement.dto.PositionDTO;
import com.gosophia.organizationManagement.ws.OrganizationManagementWebService;
@Controller("ProveAddPositionAction")
@Scope("prototype")
public class ProveAddPositionAction extends BaseAjaxAction<PositionDTO>{
    private static final long serialVersionUID = 1L;
    private Long orgId;
    private String positionName;
    private boolean result;
    @Autowired
    private OrganizationManagementWebService organizationManagementWebService;
    
    @Override
    public PositionDTO getDetailData() {
        return this.detailData;
    }
    @Override
    public String _execute() throws Exception {
        result =false;
        List<PositionDTO> positionDTOs = organizationManagementWebService.findCertainPositionByOrgId(orgId);
        if(positionDTOs!=null&&positionDTOs.size()!=0){
            for(PositionDTO pos : positionDTOs){
                if(pos.getPositionName().equals(positionName)){
                    result = true;
                    break;
                }
            }
        }
        super.getRequestResult().setRsltCode("0");
        return SUCCESS;
    }
    public boolean isResult() {
        return result;
    }
    public void setResult(boolean result) {
        this.result = result;
    }
    public Long getOrgId() {
        return orgId;
    }
    public void setOrgId(Long orgId) {
        this.orgId = orgId;
    }
    public String getPositionName() {
        return positionName;
    }
    public void setPositionName(String positionName) {
        this.positionName = positionName;
    }
    
}
